New

Syntax

Key:New(value, return)

Description

Binds a key to a Boolean variable.

Note

value can have a single value from “a” to “z”. Can also be a numeric value which represents a Key from the keyboard (ex. 96 represents 0, 97 represents 1, 98 represents 2, and so on…)

return should be a Boolean variable.

After this Key:New, the assigned Boolean variable can't be assigned thru simple:

myBoolean = false;

Read Key:Free for more info.

Example

Var:Boolean KEY_A,KEY_NUMPAD_5; //declares two Boolean variables
 
function main() {
  Screen:Show()
 
  Key:New("a",KEY_A) //bind key 'a' to 'KEY_A'
  Key:New(101,KEY_NUMPAD_5) //bind key 'numpad 5' to 'KEY_NUMPAD_5'
 
  //loop for checking if key is pressed
  while (B1 EQ false) {
    Screen:CLS()
    if (KEY_A EQ true) {
      Screen:PrintString("Key A is pressed")
    } else if (KEY_NUMPAD_5 EQ true) {
      Screen:PrintString("Key NumPad-5 is pressed")
    }
    Screen:Render()
  }
  Key:Free(KEY_A)
}
www.konsolscript.org
© 2005-2011 KonsolScript Labs | All Rights Reversed | Licensed under GNU GPL | Designed by Mj Mendoza IV
http://www.sourceforge.net